package com.server.http.handler.impl;

import com.server.conditionenum.HttpReturnStatus;
import com.server.db.DataBaseManager;
import com.server.http.handler.HttpHandler;
import com.server.http.request.HttpRequestMessage;
import com.server.http.response.HttpResponseMessage;
import com.server.mine.net.HttpProtocol;

/**
* @author	李小布
* @email	397554852@qq.com
* @version	创建时间：2018年9月26日 上午10:05:24
*/
public class ChangeWxAppid extends HttpHandler{
	@Override
	public void handle(HttpRequestMessage request, HttpResponseMessage response) {
		String failMsg = null;
		long appid = 0;
		
		String wx_appid = request.getParameter("wx_appid");
		if(wx_appid == null || wx_appid == "" ) {
			failMsg = "参数错误或参数值为空！";
		}else {
			try {
				appid = Long.parseLong(request.getParameter("appid"));
				failMsg = DataBaseManager.GetInstance().ChangeWxAppid(wx_appid, appid);
			} catch (Exception e) {
				e.printStackTrace();
				failMsg = "上传的应用编号异常!";
			}
		}
		if(failMsg == null) {
			SetReturnData(response,"修改wx_appid成功",HttpProtocol.CHANGEWXAPPID,HttpReturnStatus.Successed);
		}else {
			SetReturnData(response,failMsg,HttpProtocol.CHANGEWXAPPID,HttpReturnStatus.Failed);
		}
	}
}